# -*- encoding: utf-8 -*-
'''
@文件    :longestsubstr.py
@说明    :
@时间    :2020/05/27 11:24:17
@作者    :张钧铭
'''

class Solution(object):
    def longestCommonPrefix(self, strs):
        """
        :type strs: List[str]
        :rtype: str
        """

        if strs:
            shortest = min(strs,key=len)
        else:
            return ''

        while shortest:
            strl = [strn[:len(shortest)] for strn in strs]
            if len(set(strl))==1:
                return shortest
            else:
                shortest = shortest[:-1]
        
        return ''

s=Solution()
s.longestCommonPrefix(["flower123","flower4444","flower979790712"])
